package com.yx.coredata.common;

import com.yx.coredata.module.user.domain.User;
import com.yx.coredata.module.user.vo.UserVo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.crazycake.shiro.SerializeUtils;

import java.util.List;
import java.util.Map;

/**
 * Created by liukailong on 2017/03/07.
 */
public class CurrentUser {

    public static UserVo getUser() {
        Subject subject = SecurityUtils.getSubject();
        Map<String, Object> map = (Map<String, Object>) SerializeUtils.deserialize((byte[]) subject.getSession().getAttribute("user"));
        if(map !=null){
            return new UserVo((Long)map.get("id"),(Long)map.get("id"),(String)map.get("name"),(String)map.get("account"),(Integer)map.get("role"),(String) map.get("professionId"),(String)map.get("remark"),(String)map.get("tel"),(String)map.get("userPhoto"));
        }
        return null;
    }
}
